import name.fowler.refactoring.simplestore.domain.Customer;

import java.util.List;

import static junit.framework.Assert.assertTrue;

/**
 * User: vtatarintsev@jet.msk.su
 * Date: 07.11.13
 * Time: 8:36
 */

public class Util {
    public static Customer addCustomerAndRead(Crud crud, String name) {
        Customer customer = new Customer(name);
        crud.create(customer);
        List<Customer> customers = crud.readAll(Customer.class);
        assertTrue("Должен быть один пользователь", customers.size() == 1);
        Customer readCustomer = customers.get(0);
        assertTrue(readCustomer.getName().equals(name));
        return readCustomer;
    }
}
